package com.ruoyi.passengers.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.passengers.domain.OtherAccounts;
import com.ruoyi.passengers.service.IOtherAccountsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 第三方账号
Controller
 * 
 * @author ruoyi
 * @date 2025-08-17
 */
@RestController
@RequestMapping("/accounts")
public class OtherAccountsController extends BaseController
{
    @Autowired
    private IOtherAccountsService otherAccountsService;

    /**
     * 查询第三方账号
列表
     */
    @RequiresPermissions("passengers:accounts:list")
    @GetMapping("/list")
    public TableDataInfo list(OtherAccounts otherAccounts)
    {
        startPage();
        List<OtherAccounts> list = otherAccountsService.selectOtherAccountsList(otherAccounts);
        return getDataTable(list);
    }

    /**
     * 导出第三方账号
列表
     */
    @RequiresPermissions("passengers:accounts:export")
    @Log(title = "第三方账号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OtherAccounts otherAccounts)
    {
        List<OtherAccounts> list = otherAccountsService.selectOtherAccountsList(otherAccounts);
        ExcelUtil<OtherAccounts> util = new ExcelUtil<OtherAccounts>(OtherAccounts.class);
        util.exportExcel(response, list, "第三方账号数据");
    }

    /**
     * 获取第三方账号
详细信息
     */
    @RequiresPermissions("passengers:accounts:query")
    @GetMapping(value = "/{otherAccountsId}")
    public AjaxResult getInfo(@PathVariable("otherAccountsId") Long otherAccountsId)
    {
        return success(otherAccountsService.selectOtherAccountsByOtherAccountsId(otherAccountsId));
    }

    /**
     * 新增第三方账号

     */
    @RequiresPermissions("passengers:accounts:add")
    @Log(title = "第三方账号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OtherAccounts otherAccounts)
    {
        return toAjax(otherAccountsService.insertOtherAccounts(otherAccounts));
    }

    /**
     * 修改第三方账号

     */
    @RequiresPermissions("passengers:accounts:edit")
    @Log(title = "第三方账号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OtherAccounts otherAccounts)
    {
        return toAjax(otherAccountsService.updateOtherAccounts(otherAccounts));
    }

    /**
     * 删除第三方账号

     */
    @RequiresPermissions("passengers:accounts:remove")
    @Log(title = "第三方账号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{otherAccountsIds}")
    public AjaxResult remove(@PathVariable Long[] otherAccountsIds)
    {
        return toAjax(otherAccountsService.deleteOtherAccountsByOtherAccountsIds(otherAccountsIds));
    }
}
